package com.wn.consumer;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author yellow Docter
 * @date 2023 -07-25
 * @desc
 *  错误消费者   只能接受 error信息
 */
@Component
public class ErrorConsumer {

    /**
     * bindings   绑定   交换机和队列
     *    @Queue
     *    @Exchange
     */
    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(name = "queue-error"),
                    exchange = @Exchange(
                            name = "direct-log",
                            type = ExchangeTypes.DIRECT   // 通过 rongtingkey 发送消息到队列
                    ),
                    key = "error"
            )
    )
    public void handlerMsg(String msg){
        System.out.println("ErrorConsumer.handlerMsg===>" + msg);
    }
}
